package com.badger.spring.cloud.alibaba.provider.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.badger.spring.cloud.alibaba.provider.mapper.SeataProviderMapper;
import com.badger.spring.cloud.alibaba.provider.model.SeataProvider;

@RestController
@RequestMapping("/provider")
public class SeataProviderController {

    @Autowired
    SeataProviderMapper seataProviderMapper;

    @PostMapping("/save")
    public void saveEntity(@RequestBody SeataProvider entity) {
        seataProviderMapper.insert(entity);
    }

    @PostMapping("/ex")
    public void saveEx(@RequestBody SeataProvider entity) {
        seataProviderMapper.insert(entity);
        System.out.println(100 / 0);
    }

    @PostMapping("/timeout")
    public void saveEntityTimeOut(@RequestBody SeataProvider entity) {
        seataProviderMapper.insert(entity);
        try {
            Thread.sleep(5000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
